package exemplos.imageview2;

import javafx.application.Application;
import javafx.geometry.Rectangle2D;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
import javafx.stage.Stage;

public class ImageViewSample2 extends Application {
	
	ImageView sprite;
	private final int WIDTH = 40, HEIGHT = 40;
	private final Image SPRITE_SHEET = new Image(getClass().getResourceAsStream("spritesheet.png"));
	Thread t;
	boolean mudou = true;
	int frameCol = 0, frameLin = 0;
	
	public void start(Stage stage) {
		Group root = new Group();
		Scene scene = new Scene(root, 20, 40);
		sprite = new ImageView(SPRITE_SHEET);
		root.getChildren().add(sprite);

		sprite.setViewport(new Rectangle2D(WIDTH * frameCol, HEIGHT * frameLin, WIDTH, HEIGHT));
		
		stage.setScene(scene);
		stage.show();
	}
	
	@Override
	public void stop() throws Exception {
		System.exit(0);
	}
	
	public static void main(String[] args) { launch(args); }
}

